package com.example.ytyproject.config.exception;


import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;

/**
 * 全局异常处理器
 * 作用：异常代码可直接抛出该异常
 */
@Slf4j
@EqualsAndHashCode(callSuper = true)
public class AppException extends RuntimeException {

    private Integer code;

    private static final String ERROR = "服务异常";

    public AppException() {
        super(ERROR);
    }

    public AppException(String message) {
        super(StringUtils.isEmpty(message) ? ERROR : message);
    }

    public AppException(Integer code, String message) {
        super(message);
        this.code = code;
    }
}
